import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";

import { ContactGroup, ContactGroupGateway, Contact, ContactGateway } from "qqlx-core";
import { ContactGroupSchema, ContactSchema } from "qqlx-cdk";

import { PgDao } from "../../lib/dao.pg.id";

@Injectable()
export class ContactGroupDao extends PgDao<ContactGroup> {
  constructor(
    @InjectRepository(ContactGroupSchema)
    readonly repo: Repository<ContactGroup>,
  ) {
    super({
      repository: repo,
      relations_name: ContactGroupGateway.relations,
    });
  }
}

@Injectable()
export class ContactDao extends PgDao<Contact> {
  constructor(
    @InjectRepository(ContactSchema)
    readonly repo: Repository<Contact>,
  ) {
    super({
      repository: repo,
      relations_name: ContactGateway.relations,
    });
  }
}
